#ifndef _TIME_COUNTER_H
#define _TIME_COUNTER_H
#include <cstdio>
#include <sys/time.h>



class TimeCounter
{
public:
	TimeCounter() {reset();}
	~TimeCounter() {}
	void reset() { gettimeofday(&_start, NULL); }
	int GetTimeMilliS() {return get_interval()/1000;}
	int GetTimeMicroS() {return get_interval();}
	int GetTimeS() {return get_interval()/1000000;}
private:
	int get_interval() 
	{ 
		struct timeval now; 
		gettimeofday(&now, NULL); 
		return (now.tv_sec - _start.tv_sec)*1000000 
			+ now.tv_usec - _start.tv_usec;
	}
	struct timeval _start;
};
#endif
